--! qt:dataset:src
set hive.input.format = org.apache.hadoop.hive.ql.io.CombineHiveInputFormat;

-- This tests that the schema can be changed for binary serde data
create table partition_test_partitioned_n9(key string, value string) partitioned by (dt string) stored as rcfile;
alter table partition_test_partitioned_n9 set serde 'org.apache.hadoop.hive.serde2.columnar.LazyBinaryColumnarSerDe';
insert overwrite table partition_test_partitioned_n9 partition(dt='1') select * from src where key = 238;

select * from partition_test_partitioned_n9 where dt is not null order by key, value, dt;
select key+key, value from partition_test_partitioned_n9 where dt is not null order by key;
set hive.metastore.disallow.incompatible.col.type.changes=false;
alter table partition_test_partitioned_n9 change key key int;
reset hive.metastore.disallow.incompatible.col.type.changes;
select key+key, value from partition_test_partitioned_n9 where dt is not null order by key, value;
select * from partition_test_partitioned_n9 where dt is not null order by key, value, dt;

insert overwrite table partition_test_partitioned_n9 partition(dt='2') select * from src where key = 97;

alter table partition_test_partitioned_n9 add columns (value2 string);

select key+key, value from partition_test_partitioned_n9 where dt is not null order by key, value;
select * from partition_test_partitioned_n9 where dt is not null order by key, value, value2, dt;

insert overwrite table partition_test_partitioned_n9 partition(dt='3') select key, value, value from src where key = 200;

select key+key, value, value2 from partition_test_partitioned_n9 where dt is not null order by key, value, value2;
select * from partition_test_partitioned_n9 where dt is not null order by key, value, value2, dt;
